<?php

namespace Admin\Controller;

class LogapiController extends CommonController
{
    public function qq()
    {
        $map['alias']    = 'qq';
        $oauth           = M('Oauth')->where($map)->find();
        $oauth['config'] = unserialize($oauth['config']);
        $this->assign('oauth', $oauth);
        $this->display();
    }

    public function sina()
    {
        $map['alias']    = 'sina';
        $oauth           = M('Oauth')->where($map)->find();
        $oauth['config'] = unserialize($oauth['config']);
        $this->assign('oauth', $oauth);
        $this->display();
    }
    public function taobao()
    {
        $map['alias']    = 'taobao';
        $oauth           = M('Oauth')->where($map)->find();
        $oauth['config'] = unserialize($oauth['config']);
        $this->assign('oauth', $oauth);
        $this->display();
    }
	public function weixin()
    {
        $map['alias']    = 'weixin';
        $oauth           = M('Oauth')->where($map)->find();
        $oauth['config'] = unserialize($oauth['config']);
        $this->assign('oauth', $oauth);
        $this->display();
    }
    public function edit()
    {
        F('oauth', null);
        if (IS_POST) {
            $data = D("Oauth");
            if (!$array = $data->create()) {
                $this->error($data->getError());
            } else {
                $cfg['app_id']   = I('request.app_id');
                $cfg['app_key']  = I('request.app_key');
				$id = I('request.id');
                $array['config'] = serialize($cfg);
				if(!$id){				
				$data->add($array);	
				}else{
				$data->save($array);	
				}
                
                $this->success('保存完成');
            }
        }
    }
}